<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>信审驳回台账列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<!-- 是否显示导出台账按钮 -->
<sys:funcAuth resCd="ExportBook">
	<span id="isShowExportBtn" />
</sys:funcAuth>

<script type="text/javascript">
	var grid = null;
	var _bookTypCd = AuditConstant.AUD_REJECT_BOOK_TYP_CD;
	$(function () {
		var isShowExportBtn = $("#isShowExportBtn");
		if(isShowExportBtn.length){
			$("#exportBtn").hide();
		}
		
	    $("#ligergrid1").ligerGrid({
	    	url: '<%=path%>/audit/audStandingBook/initList.do',
	    	method : 'get',
	    	parms:{bookTypCd:_bookTypCd},
	        columns: [
	            { display: '台账编码', name: 'bookCode', width: 130},
	            { display: '添加时间', name: 'crtTm', width: 140, 
	            	render:function (rowdata, index, value){
	            		var dateStr = "";
	            		if(null != rowdata.mdfTm){
	            			var date = new Date(rowdata.mdfTm);
	            			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
	            		}else if(null != value){
	            			var date = new Date(value);
	            			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
	            		}
	            		return dateStr;
	            	}
	            },
	            { display: '操作人', name: 'crtUsrNm', width: 100,
	            	render:function (rowdata, index, value){
	            		var g = "";
	            		if(null != rowdata.mdfUsrNm){
	            			g = rowdata.mdfUsrNm;
	            		}else if(null != value){
	            			g = value;
	            		}
	            		return g;
	            	}	
	            },
	            { display: '流程编号', name: '', width: 150,
	            	render:function (rowdata, index, value){
	            		var str = "";
	            		if(StringUtils.isNotEmpty(rowdata.prjPNo)){
	            			str = rowdata.prjPNo;
	            		}else if(StringUtils.isNotEmpty(rowdata.capPNo)){
	            			str = rowdata.capPNo;
	            		}
	            		return str;
	            	}	
	            },
	            { display: '承租人', name: 'prjBscInfoVO.cstNm', width: 100},
	            { display: '客户经理', name: 'prjBscInfoVO.cstMgrNm', width: 100},
	            { display: '客户经理所属机构', name: 'prjBscInfoVO.cstMgrOrgCdNm', width: 100},
	            { display: '节点名称', name: 'taskName', width: 100},
	            { display: '评审类别', name: 'reviewTypeCdNm', width: 100},
	            { display: '审核结果', name: 'reviewResultCdNm', width: 100},
                { display: '项目名称', name: 'prjBscInfoVO.prjNm', width: 200},
	            /* { display: '操作', name: '', width: 100}, */
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'95%',
	        heightDiff:-2,
	        checkbox:true,
	        rownumbers:true,
	        onAfterShowData: function () {
	            $(".gridTip").grid_ligerTip();
	            SetIframe_height ();
	        }
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	    $("#searchBar").ligerForm();
	
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	         if($("#crtEndDt").val() != "" && $("#crtStartDt").val()>$("#crtEndDt").val()){
	        	 $.ligerDialog.SQalert({content: "添加日期(起)不能大于添加日期(止)" , SQ_type: "warning" });
	        	 return;
	         }
            var date1 = new Date();
            date1.setFullYear(date1.getFullYear()-1);
            date1.setDate(date1.getDate() + 1);
            if (StringUtils.isEmpty($("#cstNm").val()) && StringUtils.isEmpty($("#pNo").val())) {
                if (StringUtils.isEmpty($("#crtStartDt").val())){
                    grid.setParm("crtStartDt",DateUtils.formatDate(date1,DateUtils.YYYY_MM_DD));
                }
                var flag = false;
                if (StringUtils.isNotEmpty($("#crtStartDt").val()) && $("#crtStartDt").val() < DateUtils.formatDate(date1,DateUtils.YYYY_MM_DD)){
                    flag = true;
                }
                if (StringUtils.isNotEmpty($("#crtEndDt").val()) && $("#crtEndDt").val() < DateUtils.formatDate(date1,DateUtils.YYYY_MM_DD)){
                    flag = true;
                }
                if (flag){
                    top.$.ligerDialog.SQalert({content: "仅可查询添加日期至今一年内数据",SQ_type: "success"});
                    grid.setParm("crtStartDt",DateUtils.formatDate(date1,DateUtils.YYYY_MM_DD));
                }
            }
	        grid.reload();
	    });
	    $("#clearBtn").click(function(event) {
	        $("#resetBtn").click();  //重置 input-text
	        var form = liger.get("searchBar");
	    });
	    
	    $("#pageloading").hide();
	    
	});
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	//导出台账信息
	function exportBook(){
		if(StringUtils.isEmpty(_bookTypCd))return;
		var form = new liger.get("searchBar");
		var grid = liger.get("ligergrid1");
		var selectedRows = grid.getSelectedRows();
		var bookCodes = new Array();
		for(var i=0;i<selectedRows.length;i++){
			var bookCode = "'"+selectedRows[i].bookCode+"'";
			bookCodes[i] = bookCode;
		}
        var data = form.getData();
        data["bookTypCd"]=_bookTypCd;
        data["bookCodes"] = JSON.stringify(bookCodes);
        if($("#crtEndDt").val() != "" && $("#crtStartDt").val()>$("#crtEndDt").val()){
       	 $.ligerDialog.SQalert({content: "添加日期(起)不能大于添加日期(止)" , SQ_type: "warning" });
       	 return;
        }
		var wait_dialog;
		$.ajax({
			type: 'get',
			dataType:'json',
			url: '<%=path%>/audit/audStandingBook/exportBook.do?bookTypCd='+_bookTypCd,
			data:data,
			beforeSend:function(){
				wait_dialog=$.ligerDialog.SQalert({content: '正在导出台账信息...',SQ_type: "waitting"});
			},
			success:function(msg){
				wait_dialog.close();
				if(msg.success == 1){
					window.open(msg.data);
					//window.location.href = "<%=path%>/system/sysulfilesrec/downLoad.do?filePath="+ msg.data +"&fileName="+"信审驳回台账.xlsx";
				}else{
					$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				}
			} 
		});
	}
	
</script>

<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
            <div class="fieldBox">
                <div class="label">操作人</div>
                <div class="field">
                    <input name="crtRlNm" id="crtRlNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="fieldBox">
                <div class="label">承租人</div>
                <div class="field">
                    <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="fieldBox">
                <div class="label">添加日期</div>
                <div class="field">
                    <input name="crtStartDt" id="crtStartDt" type="text" class="ui-datepicker" value="" >
                     - 
                    <input name="crtEndDt" id="crtEndDt" type="text" class="ui-datepicker" value="" >
                </div>
            </div>
            <div class="fieldBox">
                <div class="label">流程编号</div>
                <div class="field">
                    <input name="pNo" id="pNo" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="clearFix"></div>
            <div class="btnsBox formBtns notRight">
                <span id="searchBtn" class="sq-button-round">查询</span>
                <span id="clearBtn" class="sq-button-round">清空</span>
                <%--<span id="exportBtn" class="sq-button-round" onclick="exportBook();" style="display: none">导出台账</span> --%>
                <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
            </div>
        </div>
        </form>
    </div>
    <div class="sqPanel" style="margin-bottom: 0;">
        <div class="sqPanel_head" style="float:left;color: red">
            <table class="table_full">
                <tr>
                    <td>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><i class="ico_flasher"></i></b>仅支持近一年内的数据查询
                    </td>
                </tr>
            </table>
        </div>
        <div id="ligergrid1" class="sq-grid"></div>
    </div>
</div>


</body>
</html>